# -*- coding: utf-8 -*-

#本文介绍了如何利用Python的Playwright库在控制台进行网页元素的调试。通过`page.pause()`设置断点，
# 结合console进行元素定位，以及使用Playwright Inspector工具辅助调试，
# 包括选择器语法支持和各种辅助方法如`playwright.$(selector)`、`playwright.locator(selector)`等。

from playwright.sync_api import Playwright, sync_playwright, expect


def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=False)
    context = browser.new_context()
    page = context.new_page()
    page.goto("http://192.168.7.136:3000/")
    page.get_by_placeholder("请输入账号").fill("028845");
    page.pause()  # 断点
    page.get_by_role("textbox", name="请输入密码").fill("Julian1!");
    page.get_by_role("button", name="登录 ").click()
    context.close()
    browser.close()



if __name__ == '__main__':
    with sync_playwright() as playwright:
        run(playwright)
